package com.sergio.compress.model.base;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.time.Instant;
import java.util.Arrays;
import java.util.Objects;

/**
 * @Author : Sergio.D
 * @Description :
 * @CreateDate ：2023/6/17 11:56
 */
public class MockDataBase {

    @Accessors(chain = true)
    @Getter
    @Setter
    private String str8;
    @Accessors(chain = true)
    @Getter
    @Setter
    private String str16;
    @Accessors(chain = true)
    @Getter
    @Setter
    private String str32;
    @Accessors(chain = true)
    @Getter
    @Setter
    private String str64;
    @Accessors(chain = true)
    @Getter
    @Setter
    private String str256;
    @Accessors(chain = true)
    @Getter
    @Setter
    private int goodsId;
    @Accessors(chain = true)
    @Getter
    @Setter
    private Instant presentAt;
    @Accessors(chain = true)
    @Getter
    @Setter
    private byte[] aa;
    @Accessors(chain = true)
    @Getter
    @Setter
    private float bb;
    @Accessors(chain = true)
    @Getter
    @Setter
    private double cc;
    @Accessors(chain = true)
    @Getter
    @Setter
    private long ee;
    @Accessors(chain = true)
    @Getter
    @Setter
    private MockDataChildBase childBase;
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MockDataBase that = (MockDataBase) o;

        StringBuilder mismatchedItems = new StringBuilder();

        if (!Objects.equals(str8, that.str8)) {
            mismatchedItems.append("str8: ").append(str8).append(" != ").append(that.str8).append("\n");
        }
        if (!Objects.equals(str16, that.str16)) {
            mismatchedItems.append("str16: ").append(str16).append(" != ").append(that.str16).append("\n");
        }
        if (!Objects.equals(str32, that.str32)) {
            mismatchedItems.append("str32: ").append(str32).append(" != ").append(that.str32).append("\n");
        }
        if (!Objects.equals(str64, that.str64)) {
            mismatchedItems.append("str64: ").append(str64).append(" != ").append(that.str64).append("\n");
        }
        if (!Objects.equals(str256, that.str256)) {
            mismatchedItems.append("str256: ").append(str256).append(" != ").append(that.str256).append("\n");
        }
        if (goodsId != that.goodsId) {
            mismatchedItems.append("goodsId: ").append(goodsId).append(" != ").append(that.goodsId).append("\n");
        }
        if (!Objects.equals(presentAt, that.presentAt)) {
            mismatchedItems.append("presentAt: ").append(presentAt).append(" != ").append(that.presentAt).append("\n");
        }
        if (!Arrays.equals(aa, that.aa)) {
            mismatchedItems.append("aa: ").append(Arrays.toString(aa)).append(" != ").append(Arrays.toString(that.aa)).append("\n");
        }
        if (Float.compare(bb, that.bb) != 0) {
            mismatchedItems.append("bb: ").append(bb).append(" != ").append(that.bb).append("\n");
        }
        if (Double.compare(cc, that.cc) != 0) {
            mismatchedItems.append("cc: ").append(cc).append(" != ").append(that.cc).append("\n");
        }
        if (ee != that.ee) {
            mismatchedItems.append("ee: ").append(ee).append(" != ").append(that.ee).append("\n");
        }
        if (!Objects.equals(childBase, that.childBase)) {
            mismatchedItems.append("childBase: ").append(childBase).append(" != ").append(that.childBase).append("\n");
        }

        if (mismatchedItems.length() > 0) {
            System.out.println("Not all properties are equal:");
            System.out.println(mismatchedItems.toString());
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        return Objects.hash(str8, str16, str32, str64, str256, goodsId, presentAt, aa, bb, cc, ee, childBase);
    }
}
